package com.gudy.counter.Controller;

import com.gudy.counter.bean.CounterRes;
import com.gudy.counter.cache.StockCache;
import com.gudy.counter.service.OrderSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/order")
public class OrderController {
    @Autowired
    private OrderSerivce orderSerivce;

    @RequestMapping(value = "/queryBalance")
    public CounterRes queryBalance(@RequestParam long uid){
        return orderSerivce.queryBalance(uid);
    };

    @RequestMapping(value = "/queryPosiInfo")
    public CounterRes queryPosiInfo(@RequestParam long uid){
        return orderSerivce.queryPosiInfo(uid);
    };
    @RequestMapping(value = "/queryOrderInfo")
    public CounterRes queryOrderInfo(@RequestParam long uid){
        return orderSerivce.queryOrderInfo(uid);
    };

    @RequestMapping(value = "/queryTradeInfo")
    public CounterRes queryTradeInfo(@RequestParam long uid){
        return orderSerivce.queryTradeInfo(uid);
    };

    @RequestMapping(value = "/getStockCode")
    public CounterRes getStockCode(@RequestParam("key") String key,@RequestParam String direction,@RequestParam long uid){
        return StockCache.getStocks(key,direction,uid);
    };
    @RequestMapping(value = "/sendorder")
    public CounterRes order(@RequestParam long uid,@RequestParam short type,@RequestParam long timestamp,@RequestParam int code,@RequestParam byte direction,@RequestParam long price,@RequestParam long volume,@RequestParam byte ordertyle,@RequestParam String token){
        return orderSerivce.OrderCmd(uid,type,timestamp,code,direction,price,volume,ordertyle,token);
    }

    @RequestMapping(value = "/saleOrder")
    public CounterRes saleOrder(@RequestParam long uid,@RequestParam short type,@RequestParam long timestamp,@RequestParam int code,@RequestParam byte direction,@RequestParam long price,@RequestParam long volume,@RequestParam byte ordertyle,@RequestParam String token){
        return orderSerivce.saleOrder(uid,type,timestamp,code,direction,price,volume,ordertyle,token);
    }
}
